package com.wngbms.spring_boot_learn.selector;

import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.ArrayList;
import java.util.List;

public class MyDeferredImportSelector2 implements DeferredImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        System.out.println("MyDeferredImportSelector2.selectImports");
        return new String[0];
    }

    @Override
    public Class<? extends Group> getImportGroup() {
        System.out.println("MyDeferredImportSelector2.getImportGroup");
        return MyGroup.class;
    }

    private static class MyGroup implements Group {

        @Override
        public void process(AnnotationMetadata metadata, DeferredImportSelector selector) {
            System.out.println("MyGroup.process");
        }

        @Override
        public Iterable<Entry> selectImports() {
            System.out.println("MyGroup.selectImports");
            /*List<String> list = new ArrayList<>();
            list.add("com.wngbms.spring_boot_learn.bean.Bean04");
            return list.stream()
                    .map(x -> new Entry(x, "bean04"))
                    .collect(Collectors.toList());*/
            List<Entry> list = new ArrayList<>();
            return list;
        }
    }

}
